<template>
	<view class="">
		<view class="he1 w100pc"></view>
		<!-- 头部 -->
		<view class="fsb lrmg-30" style="height: 100rpx;">
			<image src="/static/image/9.png" style="width:86rpx;height:50rpx" class="" @click="pageback()"></image>
			<view class="flex aic">
			</view>
		</view>
		<view class="he3 w100pc"></view>
		<view class="lrmg-30">
			<view class="gray272 weight f30">礦機資產明細</view>
			<view class="bra20 mg-t-40" style="background: #31B898;padding: 40rpx 30rpx;">
				<view class="gray333 f26">MMST總收益</view>
				<view class="weight gray333 mg-t-20" style="text-align: center;font-size: 60rpx;">{{profit}}</view>
				<view class="f26 gray333 mg-t-20 mg-r-50" style="text-align: right;">≈ $ {{(Number(profit) * Number(shouxufei.lcc_exchange)).toFixed(4)}}</view>
			</view>
			<view class="middle" v-for="(it,i) in list" :key="i" v-if="list != ''">
				<view class="gray272 weight f30">{{it.mining.label + it.mining.name}}<text style="color:#07C160" v-if="it.status == 1">(生產中)</text><text v-else style="color:red">(已结束)</text></view>
				<view class="fsb mg-t-40">
					<view class="gray272 f26">已產出天數</view>
					<view class="gray272 weight f30">{{it.day}}</view>
				</view>
				<view class="fsb mg-t-40">
					<view class="gray272 f26">已產出</view>
					<view class="gray272 weight f30">{{it.output}} MMST</view>
				</view>
				<view class="f26 mg-t-40" style="color: #c6c6c6;">剩餘天數 {{Number(it.endtime) - Number(it.day)}}天</view>
			</view>
		</view>
		<view class="he3 w100pc"></view>
		<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
		<view class="he3 w100pc"></view>
	</view>
</template>

<script>
	var	that
	import {
		_updataTabBar,
		pageto,
		pageback
	} from "../../common/js/sysfun.js"
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default{
		data(){
			return{
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '輕輕上拉',
					loading: '努力加載中',
					nomore: '實在沒有了'
				},
				list: [],
				page: 1,
				pageSize:10,
				profit:'0.00',
				shouxufei:{}
			}
		},
		onLoad() {
			that = this
			that.shouxu()
			that.getList()
		},
		methods:{
			daoqi(it){
				let total_num = Number(it.mining.total_num) //矿机总量
				let surplus_num = Number(it.mining.surplus_num) //已释放数量
				let destruction_num = Number(it.mining.destruction_num) //已销毁数量
				let everyday_num = Number(it.mining.everyday_num) //矿机每日释放
				let day = (total_num - surplus_num - destruction_num)/everyday_num
				let a = Date.now()/1000;
				let b = a + day * 86400
				let c = that.$util.formatTimes(b,'Y-M-D')
				return c
			},
			getList(){
				that.status = 'loadmore';
				that.page = 1
				let temp = {
					page:that.page,//第几页（默认第一页）
					limit:that.pageSize,//显示条数（默认10条）
				}
				that.$postAjax('api/Mining/MyList',temp,function(res){
					console.log(res);
					// console.log(that.getRequestUrl + res.data.class.pic);
					that.list = res.data.data
					that.total = res.data.total
					that.profit = res.data.profit
					if (that.total <= that.page * that.pageSize){
						that.status = 'nomore';
					}
				})
			},
			shouxu(){
				that.$postAjax('api/Finance/finance_config','',function(res){
					console.log(res);
					that.shouxufei = res.data
				})
			},
			pageto(url, pp) {
				pageto(url, pp);
			},
			pageback(){
				pageback()
			}
		},
		onReachBottom() {
			if (that.total <= that.page * that.pageSize){
				this.status = 'nomore';
				return
			} 
			this.status = 'loading';
			let postData
			postData = {
				page:that.page + 1,//第几页（默认第一页）
				limit:that.pageSize,//显示条数（默认10条）
			}
			that.$postAjax('api/Mining/MyList',postData,function(res){
				console.log(res,2222)
				that.list = that.list.concat(res.data.data)
				that.page = that.page + 1
				that.status = 'loadmore';
			})
		},
	}
</script>

<style lang="scss">
	.middle{
		background: rgba(255,255,255,.2);
		box-shadow: 0px 6rpx 23rpx 4rpx rgba(15,6,10,0.15);
		border-radius: 20rpx;
		padding: 50rpx 40rpx;
		margin-top: 30rpx;
	}
</style>